<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <p id="intro"></p>
    <button id="btn1">开始计时器</button>
    <button id="btn2">结束计时器</button>
    
    <script>
        window.addEventListener('load',()=>{
            // 1、定义变量
            let height = 100,time = null;

            // 设置定时器
            $('btn1').addEventListener('click',function(){
                time = setInterval(()=>{
                    height++;
                    $('intro').innerHTML = `小姐姐的身高是：${height} cm`;
                },1000);
            });

            // 结束定时器
            $('btn2').addEventListener('click',function(){
                clearInterval(time);
            });
        })


        function $(id){
            return typeof id === "string"?document.getElementById(id) : null;
        }
    </script>
</body>
</html>